package eleTrain.eleDBReader;

import java.sql.ResultSet;
import java.sql.Statement;

import eleTrain.poker.EleTisch;

public class DBReaderFullTilt extends DBReader {

	public DBReaderFullTilt(String db, String user, String pw) {
		super(db, user, pw, "fulhh_id_seq");
	}

	public EleHHFullTilt getNextGame() {

		return null;
	}

	@Override
	public EleHHFullTilt getRandomGame(EleTisch tisch) {
		try {
			Statement st = conn.createStatement();
			String q = "SELECT A.hh_id, A.hh FROM fullhh A, game B, gameplayer C WHERE A.game_id = B.game_id AND B.game_type_id = 7 AND B.game_id = C.game_id AND C.card_1 != '' ORDER BY RANDOM() LIMIT 1";

			ResultSet rs = st.executeQuery(q);
			if (rs.next()) {
				EleHHFullTilt eleHH = new EleHHFullTilt(rs.getString("hh"),
						tisch);
				eleHH.parse();
				return eleHH;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

}
